package com.example.smartplay.controller;


import com.example.smartplay.entity.Result;
import com.example.smartplay.utils.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class FileController {

    @Autowired
    private OssTemplate ossTemplate;

    @PostMapping("/upload")
    public Result uploadFile(MultipartFile image) throws IOException {
     String filepath=ossTemplate.upload(image.getOriginalFilename(),image.getInputStream());
     return Result.success(filepath);
    }
}
